import Vue from 'vue'
import Router from 'vue-router'
import Home from '../views/Home.vue'
import Footer from '#/Public/Footer';

Router.prototype.goBack = function () {
	this.isBack = true;
	this.history.go(-1);
};

Vue.use(Router);

export default new Router({
	mode: 'history',
	routes: [
		{
			path: '/',
			name: 'home',
			meta: {
				title: '首页',
				mode: 'in-out',
				keepAlive: true
			},
			components: {
				default: Home,
				footer: Footer
			},
		},
		{
			path: '/classify',
			name: 'classify',
			meta: {
				title: '分类',
				mode: 'in-out',
				keepAlive: true
			},
			components: {
				default: () => import('../views/Classify'),
				footer: Footer
			}
		},
		{
			path: '/classify/:id',
			meta: {
				title: '分类商品',
				mode: 'in-out'
			},
			name: 'classify-goods',
			component: () => import('../views/classify-goods')
		},
		{
			path: '/cart',
			name: 'cart',
			meta: {
				title: '购物车',
				mode: 'in-out',
				keepAlive: true
			},
			components: {
				default: () => import('../views/Cart'),
				footer: Footer
			}
		},
		{
			path: '/user',
			name: 'user',
			meta: {
				title: '个人中心',
				mode: 'in-out',
				keepAlive: true
			},
			components: {
				default: () => import('../views/User'),
				footer: Footer
			}
		},
		{
			path: '/detail/:id',
			name: 'detail',
			meta: {
				title: '商品详情',
				mode: 'in-out'
			},
			component: () => import('../views/GoodsDetail')
		},
		{
			path: '/special',
			name: 'special',
			meta: {
				title: '严选专栏',
				mode: 'in-out'
			},
			component: () => import('../views/Special')
		},
		{
			path: '/special/:id',
			meta: {
				title: '专题详情',
				mode: 'in-out'
			},
			component: () => import('../views/specialDetail')
		},
		{
			path: '/sigin',
			name: 'sigin',
			component: () => import('../views/Sigin')
		},
		{
			path: '/gift',
			name: 'gift',
			meta: {
				title: '严选礼券'
			},
			component: () => import('../views/Gift')
		},
		{
			path: '/bargain',
			name: 'bargain',
			component: () => import('../views/Bargain')
		},
		{
			path: '/login',
			name: 'login',
			meta: {
				title: '登录',
				keepAlive: true
			},
			component: () => import('../views/Login')
		},
		{
			path: '/register',
			name: 'register',
			meta: {
				title: '注册',
				keepAlive: true
			},
			component: () => import('../views/Register')
		},
		{
			path: '/purchase',
			name: 'purchase',
			meta: {
				title: '立即购买',
				login: true
			},
			component: () => import('../views/Purchase')
		},
		{
			path: '/add_address',
			name: 'addAddress',
			meta: {
				title: '新增地址',
				login: true
			},
			component: () => import('../views/addAddress')
		},
		{
			path: '/user_address',
			name: 'userAddress',
			meta: {
				title: '我的地址',
				login: true
			},
			component: () => import('../views/userAddress')
		},
		{
			path: '/update_address/:id',
			name: 'updateAddress',
			meta: {
				title: '修改地址',
				login: true
			},
			component: () => import('../views/addAddress')
		},
		{
			path: '/payment/:id',
			name: 'payment',
			meta: {
				title: '确认付款',
				login: true
			},
			component: () => import('../views/Payment')
		},
		{
			path: '/bargain/:kjid/:id',
			name: 'bargainDetail',
			meta: {
				title: '砍价商品'
			},
			component: () => import('../views/GoodsDetail')
		},
		{
			path: '/bargain_info/:id/:userId',
			name: 'bargainInfo',
			component: () => import('../views/bargainInfo')
		},
		{
			path: '*',
			name: 'error',
			component: () => import('../views/error')
		}
	]
})
